package com.codef.sharp.common.core.exception;

import com.codef.sharp.common.core.enums.ResponseStatus;

/**
 * 自定义异常
 * @author zhanrf
 * @date 2022/1/21 14:49
 */
public class SharpException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    /**
     * 状态码
     */
    private final String code;

    /**
     * 错误信息
     */
    private final String errorMessage;

    public SharpException() {
        this(ResponseStatus.FAIL.value(), ResponseStatus.FAIL.getMsg());
    }

    public SharpException(ResponseStatus responseStatus) {
        this(responseStatus.value(), responseStatus.getMsg());
    }

    public SharpException(String message) {
        this(ResponseStatus.FAIL.value(), message);
    }

    public SharpException(String code, String errorMessage) {
        this.code = code;
        this.errorMessage = errorMessage;
    }

    public String getCode() {
        return code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}
